package com.sinosoft.dsp.component.bpm.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.faces.model.SelectItem;

import org.jbpm.api.model.ActivityCoordinates;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.xsdobject.ContinueType;
import org.jbpm.xsdobject.Process;
import org.jbpm.xsdobject.TransitionType;
import org.primefaces.model.chart.flow.FlowElementSet;
import org.primefaces.model.chart.flow.FlowHop;
import org.primefaces.model.chart.flow.FlowStep;
import org.primefaces.model.chart.flow.step.FigureStep;
import org.primefaces.model.chart.flow.step.PictureStep;
import org.primefaces.model.chart.flow.util.FlowGraphHelper;

import com.sinosoft.dsp.component.bpm.exception.SinoBPMException;
import com.sinosoft.dsp.component.bpm.viewbean.activity.IBpmActivityEditViewBean;
import com.sinosoft.dsp.component.bpm.viewbean.activity.part.BpmActivityCommonBaseViewBean;
import com.sinosoft.dsp.component.bpm.viewbean.transition.IBpmTransitionEditViewBean;
import com.sinosoft.dsp.component.bpm.viewbean.transition.part.BpmTransitionCommonBaseViewBean;
import com.sinosoft.dsp.system.core.i18n.BaseMessages;
import com.sinosoft.dsp.system.utils.Const;

public enum ActivityType {
	// 开始
	Start("start", "org.jbpm.xsdobject.Process$Start", "bpm-activity-scene",
			"bpm-activity-start", "service.bpm.activity.type.start.label") {

		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Start act = (Process.Start) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep(STEP_PIC_NAME);
			Process.Start act = (Process.Start) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/start32.png");
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "start");
			step.addAttribute(FlowStep.PROVIDER, "start");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Start act = (Process.Start) activity;
			List<TransitionType> tts = act.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Start act = (Process.Start) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Start act = (Process.Start) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setDescription((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_DESC));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
			
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			TransitionType tt = (TransitionType) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Start act = (Process.Start) activity;
			name = Const.NVL(name, "");
			for (TransitionType tt : act.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			TransitionType ntt = new TransitionType();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<TransitionType> getTransitions(Object activity) {
			Process.Start act = (Process.Start) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Start obj = new org.jbpm.xsdobject.Process.Start();
			obj.setName(name);
			return obj;
		}
	},
	// 状态
	State("state", "org.jbpm.xsdobject.Process$State", "bpm-activity-scene",
			"bpm-activity-state", "service.bpm.activity.type.state.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.State act = (Process.State) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep(STEP_PIC_NAME);
			Process.State act = (Process.State) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.B_TEXT, act.getName());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/state32.png");
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "state");
			step.addAttribute(FlowStep.PROVIDER, "state");
			step.addAttribute(FlowStep.ACCEPT,
					"start,state,task,decision,fork,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.State act = (Process.State) activity;
			List<org.jbpm.xsdobject.Process.State.Transition> tts = act
					.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.State act = (Process.State) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.State act = (Process.State) activity;

			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setDescription((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_DESC));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			org.jbpm.xsdobject.Process.State.Transition tt = (org.jbpm.xsdobject.Process.State.Transition) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.State act = (Process.State) activity;
			name = Const.NVL(name, "");
			for (org.jbpm.xsdobject.Process.State.Transition tt : act
					.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			org.jbpm.xsdobject.Process.State.Transition ntt = new org.jbpm.xsdobject.Process.State.Transition();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<org.jbpm.xsdobject.Process.State.Transition> getTransitions(
				Object activity) {
			Process.State act = (Process.State) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.State obj = new org.jbpm.xsdobject.Process.State();
			obj.setName(name);
			return obj;
		}
	},
	// 判断
	Decision("decision", "org.jbpm.xsdobject.Process$Decision",
			"bpm-activity-scene", "bpm-activity-decision",
			"service.bpm.activity.type.decision.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Decision act = (Process.Decision) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep(STEP_PIC_NAME);
			Process.Decision act = (Process.Decision) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/decision32.png");
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "decision");
			step.addAttribute(FlowStep.PROVIDER, "decision");
			step.addAttribute(FlowStep.ACCEPT,
					"start,state,task,decision,fork,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Decision act = (Process.Decision) activity;
			List<org.jbpm.xsdobject.Process.Decision.Transition> tts = act
					.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Decision act = (Process.Decision) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Decision act = (Process.Decision) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setDescription((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_DESC));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			org.jbpm.xsdobject.Process.Decision.Transition tt = (org.jbpm.xsdobject.Process.Decision.Transition) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Decision act = (Process.Decision) activity;
			name = Const.NVL(name, "");
			for (org.jbpm.xsdobject.Process.Decision.Transition tt : act
					.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			org.jbpm.xsdobject.Process.Decision.Transition ntt = new org.jbpm.xsdobject.Process.Decision.Transition();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<org.jbpm.xsdobject.Process.Decision.Transition> getTransitions(
				Object activity) {
			Process.Decision act = (Process.Decision) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Decision obj = new org.jbpm.xsdobject.Process.Decision();
			obj.setName(name);
			return obj;
		}
	},
	// 结束
	End("end", "org.jbpm.xsdobject.Process$End", "bpm-activity-scene",
			"bpm-activity-end", "service.bpm.activity.type.end.label") {

		@Override
		public void setCoordinates(Object activity, String g) {
			Process.End act = (Process.End) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep(STEP_PIC_NAME);
			Process.End act = (Process.End) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/end32.png");
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "end");
			step.addAttribute(FlowStep.ACCEPT,
					"state,task,decision,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName) {
			return;
		}

		@Override
		public String getName(Object activity) {
			Process.End act = (Process.End) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.End act = (Process.End) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setDescription((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_DESC));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			return;
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			return null;
		}

		@Override
		public List<?> getTransitions(Object activity) {
			return null;
		}

		@Override
		public Object createObject(String name) {
			Process.End obj = new org.jbpm.xsdobject.Process.End();
			obj.setName(name);
			return obj;
		}
	},
	// 取消结束
	EndCancel("end-cancel", "org.jbpm.xsdobject.Process$EndCancel",
			"bpm-activity-scene", "bpm-activity-end-cancel",
			"service.bpm.activity.type.end-cancel.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.EndCancel act = (Process.EndCancel) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep(STEP_PIC_NAME);
			Process.EndCancel act = (Process.EndCancel) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/end-cancel32.png");
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "end-cancel");
			step.addAttribute(FlowStep.PROVIDER, "");
			step.addAttribute(FlowStep.ACCEPT,
					"state,task,decision,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet canvasEls, Object activity,
				int i, Map<String, Integer> activityIdAndName) {
			return;
		}

		@Override
		public String getName(Object activity) {
			Process.EndCancel act = (Process.EndCancel) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.EndCancel act = (Process.EndCancel) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setDescription((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_DESC));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			return;
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			return null;
		}

		@Override
		public List<?> getTransitions(Object activity) {
			return null;
		}

		@Override
		public Object createObject(String name) {
			Process.EndCancel obj = new org.jbpm.xsdobject.Process.EndCancel();
			obj.setName(name);
			return obj;
		}
	},
	// 错误结束
	EndError("end-error", "org.jbpm.xsdobject.Process$EndError",
			"bpm-activity-scene", "bpm-activity-end-error",
			"service.bpm.activity.type.end-error.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.EndError act = (Process.EndError) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep(STEP_PIC_NAME);
			Process.EndError act = (Process.EndError) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/end-error32.png");
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "end-error");
			step.addAttribute(FlowStep.PROVIDER, "");
			step.addAttribute(FlowStep.ACCEPT,
					"state,task,decision,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName) {
			return;
		}

		@Override
		public String getName(Object activity) {
			Process.EndError act = (Process.EndError) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.EndError act = (Process.EndError) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setDescription((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_DESC));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			return;
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			return null;
		}

		@Override
		public List<?> getTransitions(Object activity) {
			return null;
		}

		@Override
		public Object createObject(String name) {
			Process.EndError obj = new org.jbpm.xsdobject.Process.EndError();
			obj.setName(name);
			return obj;
		}
	},
	// 分支
	Fork("fork", "org.jbpm.xsdobject.Process$Fork", "bpm-activity-scene",
			"bpm-activity-fork", "service.bpm.activity.type.fork.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Fork act = (Process.Fork) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep(STEP_PIC_NAME);
			Process.Fork act = (Process.Fork) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/fork32.png");
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "fork");
			step.addAttribute(FlowStep.PROVIDER, "fork");
			step.addAttribute(FlowStep.ACCEPT,
					"start,state,task,decision,fork,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Fork act = (Process.Fork) activity;
			List<TransitionType> tts = act.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Fork act = (Process.Fork) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Fork act = (Process.Fork) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setDescription((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_DESC));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			TransitionType tt = (TransitionType) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Fork act = (Process.Fork) activity;
			name = Const.NVL(name, "");
			for (TransitionType tt : act.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			TransitionType ntt = new TransitionType();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<TransitionType> getTransitions(Object activity) {
			Process.Fork act = (Process.Fork) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Fork obj = new org.jbpm.xsdobject.Process.Fork();
			obj.setName(name);
			return obj;
		}
	},
	// 聚合
	Join("join", "org.jbpm.xsdobject.Process$Join", "bpm-activity-scene",
			"bpm-activity-join", "service.bpm.activity.type.join.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Join act = (Process.Join) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep(STEP_PIC_NAME);
			Process.Join act = (Process.Join) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/join32.png");
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "join");
			step.addAttribute(FlowStep.PROVIDER, "join");
			step.addAttribute(FlowStep.ACCEPT,
					"start,state,task,decision,fork,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Join act = (Process.Join) activity;
			List<TransitionType> tts = act.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Join act = (Process.Join) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Join act = (Process.Join) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setDescription((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_DESC));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			TransitionType tt = (TransitionType) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Join act = (Process.Join) activity;
			name = Const.NVL(name, "");
			for (TransitionType tt : act.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			TransitionType ntt = new TransitionType();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<TransitionType> getTransitions(Object activity) {
			Process.Join act = (Process.Join) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Join obj = new org.jbpm.xsdobject.Process.Join();
			obj.setName(name);
			return obj;
		}
	},
	// 人工任务
	Task("task", "org.jbpm.xsdobject.Process$Task", "bpm-activity-scene",
			"bpm-activity-task", "service.bpm.activity.type.task.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Task act = (Process.Task) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			FigureStep step = (FigureStep) FlowGraphHelper
					.createStep(STEP_FIGURE_NAME);
			Process.Task act = (Process.Task) activity;
			setActivityCoordinates(step, act.getG());
			step.setFigureType("Rectangular");
			step.addAttribute(FlowStep.C_TEXT, act.getName());
			step.addAttribute(FlowStep.CHANGABLE, Boolean.TRUE.toString());
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "task");
			step.addAttribute(FlowStep.PROVIDER, "task");
			step.addAttribute(FlowStep.ACCEPT,
					"start,state,task,decision,fork,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Task act = (Process.Task) activity;
			List<org.jbpm.xsdobject.Process.Task.Transition> tts = act
					.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Task act = (Process.Task) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Task act = (Process.Task) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setDescription((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_DESC));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			org.jbpm.xsdobject.Process.Task.Transition tt = (org.jbpm.xsdobject.Process.Task.Transition) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Task act = (Process.Task) activity;
			name = Const.NVL(name, "");
			for (org.jbpm.xsdobject.Process.Task.Transition tt : act
					.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			org.jbpm.xsdobject.Process.Task.Transition ntt = new org.jbpm.xsdobject.Process.Task.Transition();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<org.jbpm.xsdobject.Process.Task.Transition> getTransitions(
				Object activity) {
			Process.Task act = (Process.Task) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Task obj = new org.jbpm.xsdobject.Process.Task();
			obj.setName(name);
			return obj;
		}
	},
	// 子流程
	SubProcess("sub-process", "org.jbpm.xsdobject.Process$SubProcess",
			"bpm-activity-scene", "bpm-activity-sub-process",
			"service.bpm.activity.type.sub-process.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.SubProcess act = (Process.SubProcess) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep(STEP_PIC_NAME);
			Process.SubProcess act = (Process.SubProcess) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/sub-process32.png");
			step.addAttribute(FlowStep.B_TEXT, act.getName());
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "sub-process");
			step.addAttribute(FlowStep.PROVIDER, "sub-process");
			step.addAttribute(FlowStep.ACCEPT,
					"start,state,task,decision,fork,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {

			Process.SubProcess act = (Process.SubProcess) activity;
			List<org.jbpm.xsdobject.Process.SubProcess.Transition> tts = act
					.getTransition();
			if (tts != null) {
				for (org.jbpm.xsdobject.Process.SubProcess.Transition tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.SubProcess act = (Process.SubProcess) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.SubProcess act = (Process.SubProcess) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setDescription((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_DESC));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			org.jbpm.xsdobject.Process.SubProcess.Transition tt = (org.jbpm.xsdobject.Process.SubProcess.Transition) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.SubProcess act = (Process.SubProcess) activity;
			name = Const.NVL(name, "");
			for (org.jbpm.xsdobject.Process.SubProcess.Transition tt : act
					.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			org.jbpm.xsdobject.Process.SubProcess.Transition ntt = new org.jbpm.xsdobject.Process.SubProcess.Transition();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<org.jbpm.xsdobject.Process.SubProcess.Transition> getTransitions(
				Object activity) {
			Process.SubProcess act = (Process.SubProcess) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.SubProcess obj = new org.jbpm.xsdobject.Process.SubProcess();
			obj.setName(name);
			return obj;
		}
	},
	// Hql查询语言
	Hql("hql", "org.jbpm.xsdobject.Process$Hql", "bpm-activity-scene",
			"bpm-activity-hql", "service.bpm.activity.type.hql.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Hql act = (Process.Hql) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep(STEP_PIC_NAME);
			Process.Hql act = (Process.Hql) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/hql32.png");
			step.addAttribute(FlowStep.B_TEXT, act.getName());
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "hql");
			step.addAttribute(FlowStep.PROVIDER, "hql");
			step.addAttribute(FlowStep.ACCEPT,
					"start,state,task,decision,fork,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Hql act = (Process.Hql) activity;
			List<TransitionType> tts = act.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Hql act = (Process.Hql) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Hql act = (Process.Hql) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			TransitionType tt = (TransitionType) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Hql act = (Process.Hql) activity;
			name = Const.NVL(name, "");
			for (TransitionType tt : act.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			TransitionType ntt = new TransitionType();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<TransitionType> getTransitions(Object activity) {
			Process.Hql act = (Process.Hql) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Hql obj = new org.jbpm.xsdobject.Process.Hql();
			obj.setName(name);
			return obj;
		}
	},
	// Sql查询语言
	Sql("sql", "org.jbpm.xsdobject.Process$Sql", "bpm-activity-scene",
			"bpm-activity-sql", "service.bpm.activity.type.sql.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Sql act = (Process.Sql) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep(STEP_PIC_NAME);
			Process.Sql act = (Process.Sql) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/sql32.png");
			step.addAttribute(FlowStep.B_TEXT, act.getName());
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "sql");
			step.addAttribute(FlowStep.PROVIDER, "sql");
			step.addAttribute(FlowStep.ACCEPT,
					"start,state,task,decision,fork,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Sql act = (Process.Sql) activity;
			List<TransitionType> tts = act.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Sql act = (Process.Sql) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Sql act = (Process.Sql) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			TransitionType tt = (TransitionType) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Sql act = (Process.Sql) activity;
			name = Const.NVL(name, "");
			for (TransitionType tt : act.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			TransitionType ntt = new TransitionType();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<TransitionType> getTransitions(Object activity) {
			Process.Sql act = (Process.Sql) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Sql obj = new org.jbpm.xsdobject.Process.Sql();
			obj.setName(name);
			return obj;
		}
	},
	// Java程序
	Java("java", "org.jbpm.xsdobject.Process$Java", "bpm-activity-scene",
			"bpm-activity-java", "service.bpm.activity.type.java.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Java act = (Process.Java) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep(STEP_PIC_NAME);
			Process.Java act = (Process.Java) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/java32.png");
			step.addAttribute(FlowStep.B_TEXT, act.getName());
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "java");
			step.addAttribute(FlowStep.PROVIDER, "java");
			step.addAttribute(FlowStep.ACCEPT,
					"start,state,task,decision,fork,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Java act = (Process.Java) activity;
			List<TransitionType> tts = act.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Java act = (Process.Java) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Java act = (Process.Java) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			TransitionType tt = (TransitionType) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Java act = (Process.Java) activity;
			name = Const.NVL(name, "");
			for (TransitionType tt : act.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			TransitionType ntt = new TransitionType();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<TransitionType> getTransitions(Object activity) {
			Process.Java act = (Process.Java) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Java obj = new org.jbpm.xsdobject.Process.Java();
			obj.setName(name);
			return obj;
		}
	},
	// 脚本
	Script("script", "org.jbpm.xsdobject.Process$Script", "bpm-activity-scene",
			"bpm-activity-script", "service.bpm.activity.type.script.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Script act = (Process.Script) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep(STEP_PIC_NAME);
			Process.Script act = (Process.Script) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/script32.png");
			step.addAttribute(FlowStep.B_TEXT, act.getName());
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "script");
			step.addAttribute(FlowStep.PROVIDER, "script");
			step.addAttribute(FlowStep.ACCEPT,
					"start,state,task,decision,fork,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Script act = (Process.Script) activity;
			List<TransitionType> tts = act.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Script act = (Process.Script) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Script act = (Process.Script) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			TransitionType tt = (TransitionType) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Script act = (Process.Script) activity;
			name = Const.NVL(name, "");
			for (TransitionType tt : act.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			TransitionType ntt = new TransitionType();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<TransitionType> getTransitions(Object activity) {
			Process.Script act = (Process.Script) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Script obj = new org.jbpm.xsdobject.Process.Script();
			obj.setName(name);
			return obj;
		}
	},
	// 邮件
	Mail("mail", "org.jbpm.xsdobject.Process$Mail", "bpm-activity-scene",
			"bpm-activity-mail", "service.bpm.activity.type.mail.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Mail act = (Process.Mail) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			PictureStep step = (PictureStep) FlowGraphHelper
					.createStep("STEP_PIC_NAME");
			Process.Mail act = (Process.Mail) activity;
			setActivityCoordinates(step, act.getG());
			step.addAttribute(PictureStep.S_IMG_SRC,
					"img/component/bpm/jpdl/mail32.png");
			step.addAttribute(PictureStep.B_TEXT, act.getName());
			step.addExtendData(ATTRIBUTE_NAME, act.getName());
			step.addExtendData(ATTRIBUTE_TYPE, "mail");
			step.addAttribute(FlowStep.PROVIDER, "mail");
			step.addAttribute(FlowStep.ACCEPT,
					"start,state,task,decision,fork,join,sub-process");
			return step;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Mail act = (Process.Mail) activity;
			List<TransitionType> tts = act.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Mail act = (Process.Mail) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Mail act = (Process.Mail) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			TransitionType tt = (TransitionType) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Mail act = (Process.Mail) activity;
			name = Const.NVL(name, "");
			for (TransitionType tt : act.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			TransitionType ntt = new TransitionType();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<TransitionType> getTransitions(Object activity) {
			Process.Mail act = (Process.Mail) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Mail obj = new org.jbpm.xsdobject.Process.Mail();
			obj.setName(name);
			return obj;
		}
	},
	// 组
	Group("group", "org.jbpm.xsdobject.Process$Group", "bpm-activity-scene",
			"bpm-activity-group", "service.bpm.activity.type.group.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Group act = (Process.Group) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			return null;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Group act = (Process.Group) activity;
			List<TransitionType> tts = act.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Group act = (Process.Group) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Mail act = (Process.Mail) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			TransitionType tt = (TransitionType) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Group act = (Process.Group) activity;
			name = Const.NVL(name, "");
			for (TransitionType tt : act.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			TransitionType ntt = new TransitionType();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<TransitionType> getTransitions(Object activity) {
			Process.Group act = (Process.Group) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Group obj = new org.jbpm.xsdobject.Process.Group();
			obj.setName(name);
			return obj;
		}
	},
	// 自定义
	Custom("custom", "org.jbpm.xsdobject.Process$Custom", "bpm-activity-scene",
			"bpm-activity-custom", "service.bpm.activity.type.custom.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Custom act = (Process.Custom) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			return null;
		}

		@Override
		public void createCanvasHops(FlowElementSet canvasEls, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Custom act = (Process.Custom) activity;
			List<TransitionType> tts = act.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(canvasEls.getStep(i));
					hop.setToEl(canvasEls.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					canvasEls.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Custom act = (Process.Custom) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Custom act = (Process.Custom) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			TransitionType tt = (TransitionType) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Custom act = (Process.Custom) activity;
			name = Const.NVL(name, "");
			for (TransitionType tt : act.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			TransitionType ntt = new TransitionType();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<TransitionType> getTransitions(Object activity) {
			Process.Custom act = (Process.Custom) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Custom obj = new org.jbpm.xsdobject.Process.Custom();
			obj.setName(name);
			return obj;
		}
	},
	// 规则
	Rules("rules", "org.jbpm.xsdobject.Process$Rules", "bpm-activity-scene",
			"bpm-activity-rules", "service.bpm.activity.type.rules.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Rules act = (Process.Rules) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			return null;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Rules act = (Process.Rules) activity;
			List<org.jbpm.xsdobject.Process.Rules.Transition> tts = act
					.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Rules act = (Process.Rules) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Rules act = (Process.Rules) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			TransitionType tt = (TransitionType) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Rules act = (Process.Rules) activity;
			name = Const.NVL(name, "");
			for (org.jbpm.xsdobject.Process.Rules.Transition tt : act
					.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			org.jbpm.xsdobject.Process.Rules.Transition ntt = new org.jbpm.xsdobject.Process.Rules.Transition();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<org.jbpm.xsdobject.Process.Rules.Transition> getTransitions(
				Object activity) {
			Process.Rules act = (Process.Rules) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Rules obj = new org.jbpm.xsdobject.Process.Rules();
			obj.setName(name);
			return obj;
		}
	},
	// 规则判断
	RulesDecision("rules-decision", "org.jbpm.xsdobject.Process$RulesDecision",
			"bpm-activity-scene", "bpm-activity-rules-decision",
			"service.bpm.activity.type.rules-decision.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.RulesDecision act = (Process.RulesDecision) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			return null;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.RulesDecision act = (Process.RulesDecision) activity;
			List<TransitionType> tts = act.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.RulesDecision act = (Process.RulesDecision) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.RulesDecision act = (Process.RulesDecision) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			TransitionType tt = (TransitionType) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.RulesDecision act = (Process.RulesDecision) activity;
			name = Const.NVL(name, "");
			for (TransitionType tt : act.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			TransitionType ntt = new TransitionType();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<TransitionType> getTransitions(Object activity) {
			Process.RulesDecision act = (Process.RulesDecision) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.RulesDecision obj = new org.jbpm.xsdobject.Process.RulesDecision();
			obj.setName(name);
			return obj;
		}
	},
	// JMS消息
	Jms("jms", "org.jbpm.xsdobject.Process$Jms", "bpm-activity-scene",
			"bpm-activity-jms", "service.bpm.activity.type.jms.label") {
		@Override
		public void setCoordinates(Object activity, String g) {
			Process.Jms act = (Process.Jms) activity;
			act.setG(g);
		}

		@Override
		public FlowStep createCanvasStep(Object activity)
				throws SinoBPMException {
			return null;
		}

		@Override
		public void createCanvasHops(FlowElementSet els, Object activity,
				int i, Map<String, Integer> activityIdAndName)
				throws SinoBPMException {
			Process.Jms act = (Process.Jms) activity;
			List<TransitionType> tts = act.getTransition();
			if (tts != null) {
				for (TransitionType tt : tts) {
					int toIndex = activityIdAndName.get(tt.getTo());
					FlowHop hop = FlowGraphHelper.createHop();
					hop.setFromEl(els.getStep(i));
					hop.setToEl(els.getStep(toIndex));
					hop.addAttribute(FlowHop.TEXT, tt.getName());
					hop.addExtendData(ATTRIBUTE_NAME, tt.getName());
					ActivityType.setHopG(hop, tt.getG());
					hop.createId();
					els.addHop(hop);
				}
			}
		}

		@Override
		public String getName(Object activity) {
			Process.Jms act = (Process.Jms) activity;
			return act.getName();
		}

		@Override
		public void createOrUpdateActivity(Object activity,
				IBpmActivityEditViewBean ae) {
			Process.Jms act = (Process.Jms) activity;
			act.setName((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_NAME));
			act.setContinue(ContinueType.fromValue((String) ae
					.getField(BpmActivityCommonBaseViewBean.FIELD_CONTINUE)));
		}

		@Override
		public void createOrUpdateTransisionObject(Object trans,
				IBpmTransitionEditViewBean te) {
			TransitionType tt = (TransitionType) trans;
			tt.setName((String) te
					.getField(BpmTransitionCommonBaseViewBean.FIELD_NAME));
			tt
					.setTo((String) te
							.getField(BpmTransitionCommonBaseViewBean.FIELD_TO_ACTIVITY_NAME));
			tt
					.getDescription()
					.add(
							(String) te
									.getField(BpmTransitionCommonBaseViewBean.FIELD_DESC));
		}

		@Override
		public TransitionType createOrUpdateTransition(Object activity,
				String name, String toActName, String g) {
			Process.Jms act = (Process.Jms) activity;
			name = Const.NVL(name, "");
			for (TransitionType tt : act.getTransition()) {
				if (name.equals(Const.NVL(tt.getName(), ""))) {
					tt.setG(g);
					return tt;
				}
			}
			// 创建新的连线
			TransitionType ntt = new TransitionType();
			ntt.setName(name);
			ntt.setTo(toActName);
			ntt.setG(g);
			act.getTransition().add(ntt);
			return ntt;
		}

		@Override
		public List<TransitionType> getTransitions(Object activity) {
			Process.Jms act = (Process.Jms) activity;
			return act.getTransition();
		}

		@Override
		public Object createObject(String name) {
			Process.Jms obj = new org.jbpm.xsdobject.Process.Jms();
			obj.setName(name);
			return obj;
		}
	};

	private static final String PKG = "com.sinosoft.dsp.component.bpm";

	public static final String ATTRIBUTE_NAME = "name";

	public static final String ATTRIBUTE_TYPE = "type";

	public static final String STEP_PIC_NAME = "sys:step:picture";

	public static final String STEP_FIGURE_NAME = "sys:step:figure";

	private static List<SelectItem> items;

	private String tagName;

	private String className;

	private String displayName;

	private String sceneId;

	private String layoutId;

	ActivityType(String tagName, String className, String sceneId,
			String layoutId, String displayName) {
		this.tagName = tagName;
		this.className = className;
		this.sceneId = sceneId;
		this.layoutId = layoutId;
		this.displayName = displayName;
	}

	public String getTagName() {
		return tagName;
	}

	public String getClassName() {
		return className;
	}

	public String getDisplayName() {
		return BaseMessages.getString(PKG, displayName);
	}

	public String getSceneId() {
		return sceneId;
	}

	public String getLayoutId() {
		return layoutId;
	}

	public static ActivityType getActivityType(String name) {
		for (ActivityType a : ActivityType.values()) {
			if (a.tagName.equalsIgnoreCase(name)) {
				return a;
			}
		}
		return null;
	}

	public static ActivityType getActivityType(Class<?> clazz) {
		for (ActivityType a : ActivityType.values()) {
			if (a.className.equals(clazz.getName())) {
				return a;
			}
		}
		return null;
	}

	public static String getActivityName(Object activity) {
		if (activity != null) {
			ActivityType at = ActivityType.getActivityType(activity.getClass());
			return at.getName(activity);
		}
		return null;
	}

	public static void createOrUpdateActivityObject(Object activity,
			IBpmActivityEditViewBean ae) {
		if (activity != null) {
			ActivityType at = ActivityType.getActivityType(activity.getClass());
			at.createOrUpdateActivity(activity, ae);
		}
	}

	public static TransitionType createOrUpdateActivityTransition(
			Object activity, String name, String toActName, String g) {
		if (activity != null) {
			ActivityType at = ActivityType.getActivityType(activity.getClass());
			return at.createOrUpdateTransition(activity, name, toActName, g);
		}
		return null;
	}

	public static List<?> getActivityTransitions(Object activity) {
		if (activity != null) {
			ActivityType at = ActivityType.getActivityType(activity.getClass());
			return at.getTransitions(activity);
		}
		return null;
	}

	public static List<SelectItem> getActivityTypeItems() {
		if (items == null) {
			items = new ArrayList<SelectItem>();
			for (ActivityType at : ActivityType.values()) {
				items.add(new SelectItem(at.getTagName(), at.getDisplayName()));
			}
		}
		return items;
	}

	public static void setHopG(FlowHop hop, String g) {
		int[] x = null, y = null;
		if (!Const.isEmpty(g)) {
			String[] gs = g.split(",");
			if (gs.length > 4) {
				x = new int[gs.length / 2];
				y = new int[gs.length / 2];
				for (int i = 0; i < gs.length / 2; i++) {
					x[i] = Integer.valueOf(gs[i * 2]);
					y[i] = Integer.valueOf(gs[i * 2 + 1]);
				}
			}
		}
		if (x == null) {
			x = new int[] { 0, 0 };
			y = new int[] { 0, 0 };
		}
		hop.setX(x);
		hop.setY(y);
	}

	public void setActivityCoordinates(FlowStep step, String g) {
		ActivityCoordinates coord = XmlUtil.parserActivityCoordinates(g);
		step.addAttribute(FlowStep.D_X, String.valueOf(coord.getX()));
		step.addAttribute(FlowStep.D_Y, String.valueOf(coord.getY()));
		step.addAttribute(FlowStep.D_WIDTH, String.valueOf(coord.getWidth()));
		step.addAttribute(FlowStep.D_HEIGHT, String.valueOf(coord.getHeight()));
	}

	public static void setActivityCoordinates(Object activity, String g) {
		ActivityType at = getActivityType(activity.getClass());
		at.setCoordinates(activity, g);
	}

	public abstract void setCoordinates(Object activity, String g);

	public abstract Object createObject(String name);

	public abstract String getName(Object activity);

	public abstract void createOrUpdateActivity(Object activity,
			IBpmActivityEditViewBean ae);

	public abstract TransitionType createOrUpdateTransition(Object activity,
			String name, String toActName, String g);

	public abstract void createOrUpdateTransisionObject(Object trans,
			IBpmTransitionEditViewBean te);

	public abstract List<?> getTransitions(Object activity);

	public abstract FlowStep createCanvasStep(Object activity)
			throws SinoBPMException;

	public abstract void createCanvasHops(FlowElementSet els, Object activity,
			int i, Map<String, Integer> activityIdAndName)
			throws SinoBPMException;
}
